let sleep2 = (time) => new Promise((resolve) => {
    setTimeout(resolve, time)
})


async function changeColor (color, duration) {
    console.log('traffice-light', color)
    await sleep2(duration)
}

async function main() {
    while(true) {
        await changeColor('red', 2000);
        await changeColor('yellow', 1000);
        await changeColor('green', 3000);
    }
    
}

main();